<?php

namespace app\libs\TongtuSDK\Action;

use App\Libs\TongtuSDK\Model\OrderModel;
use app\libs\TongtuSDK\TongTuClient;

class OrderApi extends TongTuClient
{
    /**
     * @see https://open.tongtool.com/apiDoc.html#/?docId=908e49d8bf62487aa870335ef6951567
     *
     */
    public function orderImport(array $orderParams)
    {
        return self::post(
            '/openapi/tongtool/orderImport',
            [
                'query'=>[
                    'order'=>$orderParams,
                    'merchantId'=>self::MERCHANT_ID
                ],
            ]
        );
    }

    /**
     * @param $orderIds
     * @see https://open.tongtool.com/apiDoc.html#/?docId=3b3cceec8fe04e6db44da17ec4b38f08
     */
    public function trackingNumberQuery($orderIds,$page = 1,$pageSize = 100)
    {
        return self::post('/openapi/tongtool/trackingNumberQuery',[
            'query'=>[
                'merchantId'=>self::MERCHANT_ID,
                'orderIds'=>$orderIds,
                'pageNo'=>$page,
                'pageSize'=>$pageSize,
            ]
        ]);
    }

    //订单查询
    public function orderQuery()
    {
        return self::post(
            '/openapi/tongtool/ordersQuery',
            [
                'query'=>[
                    'accountCode'=>'0ad537A',
                    'merchantId'=>self::MERCHANT_ID,
                    'storeFlag'=>0,
                    'payDateFrom'=>'2023-09-01 00:00:00',
                    'payDateTo'=>'2023-09-11 23:59:59',
                    'pageNo'=>1,
                    'pageSize'=>20
                ],
            ],
        );
    }
}
